#define  _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct vertex {
	int vername;
	struct edge* adjacent;
};
struct edge {
	int veradj;
	edge* link;
};
struct vertex head[110];
struct edge* newedge;
struct edge* ptr;
void build(int a, int b) {
	newedge = (struct edge*)malloc(sizeof(struct edge));
	newedge->veradj = b;
	newedge->link = NULL;
	if (head[a].adjacent == NULL) head[a].adjacent = newedge;
	else {
		ptr = head[a].adjacent;
		while (ptr->link != NULL) {
			ptr = ptr->link;
		}
		ptr->link = newedge;
	}
}
bool toporder(struct vertex head[], int n, int indegree[]) {
	int stack[110], top = -1;
	for (int i = 0; i < n; i++) {if (indegree[i] == 0) stack[++top] = i;}
	for (int i = 0; i < n; i++) { 
		if (top == -1) return false; 
		int j = stack[top--];
		printf("%d ", j);
		for (struct edge* p = head[j].adjacent; p != NULL; p = p->link)
			if (--indegree[p->veradj] == 0) stack[++top] = p->veradj;
	
	}
	return true;
}
int main() {
	int n, e;
	int indegree[110];
	int value[110][2];
	scanf("%d %d", &n, &e);
	int i;
	for (i = 0; i < n; i++) {
		indegree[i] = 0;
	}
	
	for (i = 0; i < e; i++) {
		scanf("%d %d", &value[i][0], &value[i][1]);
		indegree[value[i][1]]++;
	}
	for (i = 0; i < n; i++) {
		head[i].vername = i;
		head[i].adjacent = NULL;
	}
	for (i = 0; i < e; i++) { build(value[i][0], value[i][1]); }
	bool k;
	k = toporder(head,n, indegree);
	if (k==false) printf("unworkable project");
	return 0;
}
